package com.xbongbong.saas.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.saas.enums.business.BomBillEnum;
import com.xbongbong.saas.enums.business.ClueEnum;
import com.xbongbong.saas.enums.business.CommunicatePlanEnum;
import com.xbongbong.saas.enums.business.CompetitorEnum;
import com.xbongbong.saas.enums.business.ContactEnum;
import com.xbongbong.saas.enums.business.ContractEnum;
import com.xbongbong.saas.enums.business.CustomerManagementEnum;
import com.xbongbong.saas.enums.business.InventoryEnum;
import com.xbongbong.saas.enums.business.InvoiceEnum;
import com.xbongbong.saas.enums.business.MarketActivityEnum;
import com.xbongbong.saas.enums.business.PayPlanEnum;
import com.xbongbong.saas.enums.business.PaySheetEnum;
import com.xbongbong.saas.enums.business.PaymentEnum;
import com.xbongbong.saas.enums.business.PaymentSheetEnum;
import com.xbongbong.saas.enums.business.PaymentTaskEnum;
import com.xbongbong.saas.enums.business.ProductEnum;
import com.xbongbong.saas.enums.business.ProductionOrderEnum;
import com.xbongbong.saas.enums.business.PurchaseEnum;
import com.xbongbong.saas.enums.business.PurchaseInvoiceEnum;
import com.xbongbong.saas.enums.business.QuotationEnum;
import com.xbongbong.saas.enums.business.RefundEnum;
import com.xbongbong.saas.enums.business.ReturnedPurchaseEnum;
import com.xbongbong.saas.enums.business.SalesOpportunityEnum;
import com.xbongbong.saas.enums.business.SupplierContactEnum;
import com.xbongbong.saas.enums.business.SupplierEnum;
import com.xbongbong.saas.enums.business.TransferEnum;
import com.xbongbong.saas.enums.business.WarehouseEnum;
import com.xbongbong.saas.enums.business.WorkOrderEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 关联业务选择弹窗页表头字段
 *
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/1/23 9:34
 * @since v1.0
 */
@Getter
public enum BusinessFieldEnum {
    // 关联业务选择弹窗页表头
    CUSTOMER(RedundantTemplateTypeEnum.CUSTOMER.getCode(), Arrays.asList(CustomerManagementEnum.NAME.getAttr(), CustomerManagementEnum.TYPE.getAttr(), FieldTypeEnum.ADDTIME.getAlias(), CustomerManagementEnum.LAST_CONNECT_TIME.getAttr())),
    PRODUCT(RedundantTemplateTypeEnum.PRODUCT.getCode(),  Arrays.asList(ProductEnum.PRODUCT_IMGS.getAttr(), ProductEnum.NAME.getAttr(), ProductEnum.SERIALNO.getAttr(), ProductEnum.SPECIFICATION.getAttr(), ProductEnum.COST.getAttr(), ProductEnum.PRICE.getAttr(), ProductEnum.UNIT.getAttr())),
    // TODO 销售阶段以后再加
    SALES_OPPORTUNITY(RedundantTemplateTypeEnum.SALES_OPPORTUNITY.getCode(), Arrays.asList(SalesOpportunityEnum.SERIAL_NO.getAttr(), SalesOpportunityEnum.NAME.getAttr(), FieldTypeEnum.ADDTIME.getAlias(),SalesOpportunityEnum.ESTIMATE_END_TIME.getAttr())),
    CONTRACT(RedundantTemplateTypeEnum.CONTRACT.getCode(), Arrays.asList(ContractEnum.CONTRACT_NO.getAttr(), ContractEnum.NAME.getAttr(), ContractEnum.AMOUNT.getAttr(),ContractEnum.SIGN_TIME.getAttr())),
    PURCHASE(RedundantTemplateTypeEnum.PURCHASE.getCode(), Arrays.asList(PurchaseEnum.SHEET_NO.getAttr(), PurchaseEnum.PURCHASE_NAME.getAttr(), PurchaseEnum.TOTAL_MONEY.getAttr(),PurchaseEnum.SIGN_TIME.getAttr())),
    CONTACT(RedundantTemplateTypeEnum.CONTACT.getCode(), Arrays.asList(ContactEnum.NAME.getAttr(), ContactEnum.PHONE.getAttr())),
    COMMUNICATE_PLAN(RedundantTemplateTypeEnum.COMMUNICATE_PLAN.getCode(), Arrays.asList(CommunicatePlanEnum.NAME.getAttr(), CommunicatePlanEnum.COMMUNICATE_TIME.getAttr(), CommunicatePlanEnum.MEMO.getAttr())),
    SUPPLIER(RedundantTemplateTypeEnum.SUPPLIER.getCode(), Arrays.asList(SupplierEnum.SUPPLIER_NAME.getAttr(), SupplierEnum.PHONE.getAttr(),SupplierEnum.ADDRESS.getAttr())),
    SUPPLIER_CONTACT(RedundantTemplateTypeEnum.SUPPLIER_CONTACT.getCode(), Arrays.asList(SupplierContactEnum.NAME.getAttr(), SupplierContactEnum.PHONE.getAttr())),
    WAREHOUSE(RedundantTemplateTypeEnum.WAREHOUSE.getCode(), Arrays.asList(WarehouseEnum.WAREHOUSE_NAME.getAttr(), WarehouseEnum.WAREHOUSE_NO.getAttr())),
    PAYMENT(RedundantTemplateTypeEnum.PAYMENT.getCode(), Arrays.asList(PaymentEnum.PAYMENT_NO.getAttr(), PaymentEnum.AMOUNT.getAttr(),PaymentEnum.ESTIMATE_TIME.getAttr())),
    BOM_BILL(RedundantTemplateTypeEnum.BOMBILL.getCode(), Arrays.asList(BomBillEnum.SHEET_NO.getAttr(), BomBillEnum.NAME.getAttr(), BomBillEnum.VERSION.getAttr(), BomBillEnum.PRODUCT_NAME_HIDE.getAttr(), BomBillEnum.PRODUCT_NO.getAttr(), BomBillEnum.PRODUCT_SPECIFICATION.getAttr())),
    PAYMENT_SHEET(RedundantTemplateTypeEnum.PAYMENT_SHEET.getCode(), Arrays.asList(PaymentSheetEnum.SHEET_NO.getAttr(), PaymentSheetEnum.AMOUNT.getAttr(), PaymentSheetEnum.WRITE_OFF_AMOUNT.getAttr(), PaymentSheetEnum.PAYMENT_TIME.getAttr(), PaymentSheetEnum.BELONG_ID.getAttr(), PaymentSheetEnum.RED_SHEET.getAttr(), PaymentSheetEnum.PAYMENT_SHEET_TYPE.getAttr())),
    PAY_SHEET(RedundantTemplateTypeEnum.PAY_SHEET.getCode(), Arrays.asList(PaySheetEnum.PAY_PLAN_NO.getAttr(), PaySheetEnum.AMOUNT.getAttr(), PaySheetEnum.WRITE_OFF_AMOUNT.getAttr(), PaySheetEnum.REAL_PAY_TIME.getAttr(), PaySheetEnum.BELONG_ID.getAttr(), PaySheetEnum.ORIGIN_ID.getAttr(), PaySheetEnum.PAY_SHEET_TYPE.getAttr())),
    INVENTORY(RedundantTemplateTypeEnum.INVENTORY.getCode(), Arrays.asList(InventoryEnum.SHEET_NO.getAttr(), InventoryEnum.WAREHOUSE_ID.getAttr(), InventoryEnum.WAREHOUSE_ID_LINKED_TEXT.getAttr())),
    TRANSFER(RedundantTemplateTypeEnum.TRANSFER.getCode(), Arrays.asList(TransferEnum.SHEET_NO.getAttr(), TransferEnum.INTO_WAREHOUSE_ID.getAttr(), TransferEnum.INTO_WAREHOUSE_ID_LINKED_TEXT.getAttr(), TransferEnum.OUT_WAREHOUSE_ID.getAttr(), TransferEnum.OUT_WAREHOUSE_ID_LINKED_TEXT.getAttr())),
    PRODUCTION_ORDER(RedundantTemplateTypeEnum.PRODUCTIONORDER.getCode(), Arrays.asList(ProductionOrderEnum.SHEET_NO.getAttr(), ProductionOrderEnum.INTO_WAREHOUSE_ID.getAttr(), ProductionOrderEnum.INTO_WAREHOUSE_ID_LINK_TEXT.getAttr(), ProductionOrderEnum.OUT_WAREHOUSE_ID.getAttr(), ProductionOrderEnum.OUT_WAREHOUSE_ID_LINK_TEXT.getAttr())),
    RETURNED_PURCHASE(RedundantTemplateTypeEnum.RETURNED_PURCHASE.getCode(), Arrays.asList(ReturnedPurchaseEnum.SHEET_NO.getAttr())),
    INVOICE(RedundantTemplateTypeEnum.INVOICE.getCode(), Arrays.asList(InvoiceEnum.SHEET_NO.getAttr(), InvoiceEnum.TOTAL_MONEY.getAttr(), InvoiceEnum.INVOICE_DATE.getAttr())),
    PURCHASE_INVOICE(RedundantTemplateTypeEnum.PURCHASE_INVOICE.getCode(),Arrays.asList(PurchaseInvoiceEnum.SHEET_NO.getAttr(), PurchaseInvoiceEnum.TOTAL_MONEY.getAttr(), PurchaseInvoiceEnum.INVOICE_DATE.getAttr())),
    REFUND(RedundantTemplateTypeEnum.REFUND.getCode(), Arrays.asList(RefundEnum.REFUND_NO.getAttr(), RefundEnum.REFUND_NAME.getAttr(), RefundEnum.RETURN_AMOUNT.getAttr())),
    WORK_ORDER(RedundantTemplateTypeEnum.WORKORDER.getCode(), Arrays.asList(WorkOrderEnum.SHEET_NO.getAttr(), WorkOrderEnum.NAME.getAttr())),
    QUOTATION(RedundantTemplateTypeEnum.QUOTATION.getCode(), Arrays.asList(QuotationEnum.QUOTATION_NO.getAttr(), QuotationEnum.NAME.getAttr(), QuotationEnum.AMOUNT.getAttr())),
    MARKET_ACTIVITY(RedundantTemplateTypeEnum.MARKET_ACTIVITY.getCode(),Arrays.asList(MarketActivityEnum.NAME.getAttr(), MarketActivityEnum.GENRE.getAttr(),MarketActivityEnum.STATUS.getAttr(),MarketActivityEnum.ADD_TIME.getAttr())),
    CLUE(RedundantTemplateTypeEnum.CLUE.getCode(),Arrays.asList(ClueEnum.COMPANY_NAME.getAttr(), ClueEnum.CLUE_STATUS.getAttr(),ClueEnum.ADD_TIME.getAttr())),
    PAYPLAN(RedundantTemplateTypeEnum.PAY_PLAN.getCode(),Arrays.asList(PayPlanEnum.PAY_PLAN_NO.getAttr(), PayPlanEnum.AMOUNT.getAttr(),PayPlanEnum.ESTIMATE_TIME.getAttr())),
    PAYMENT_TASK(RedundantTemplateTypeEnum.PAYMENT_TASK.getCode(),Arrays.asList(PaymentTaskEnum.PAYMENT_TASK_NO.getAttr(), PaymentTaskEnum.LINK_CUSTOMER.getAttr(),PaymentTaskEnum.LINK_CUSTOMER_HIDE.getAttr(), PaymentTaskEnum.LINK_CONTRACT.getAttr(), PaymentTaskEnum.LINK_CONTRACT_HIDE.getAttr(), PaymentTaskEnum.PAYMENT_TASK_NUM.getAttr(), PaymentTaskEnum.EXECUTOR_TIME.getAttr())),
    WAIT_PURCHASE(XbbRefTypeEnum.WAIT_PURCHASE.getCode(),Arrays.asList(ContractEnum.NAME.getAttr(), ContractEnum.CONTRACT_NO.getAttr(),ContractEnum.LINK_CUSTOMER.getAttr(),ContractEnum.CREATOR_ID.getAttr(),ContractEnum.ADD_TIME.getAttr(),ContractEnum.UPDATE_TIME.getAttr())),
    WAIT_OUTSTOCK(XbbRefTypeEnum.WAIT_OUTSTOCK.getCode(),Arrays.asList(ContractEnum.NAME.getAttr(), ContractEnum.CONTRACT_NO.getAttr(),ContractEnum.LINK_CUSTOMER.getAttr(),ContractEnum.STATUS.getAttr(),ContractEnum.SIGN_TIME.getAttr(),ContractEnum.OWNER_ID.getAttr(),ContractEnum.MINOR_USER.getAttr(),ContractEnum.CREATOR_ID.getAttr(),ContractEnum.ADD_TIME.getAttr(),ContractEnum.UPDATE_TIME.getAttr())),
    COMPETITOR(XbbRefTypeEnum.COMPETITOR.getCode(),Arrays.asList(CompetitorEnum.NAME.getAttr(),CompetitorEnum.ADDRESS.getAttr(),CompetitorEnum.WEBSITE.getAttr())),
    ;

    private Integer businessType;
    private List<String> fieldList;

    BusinessFieldEnum(Integer businessType, List<String> fieldList) {
        this.businessType = businessType;
        this.fieldList = fieldList;
    }

    public static List<String> getByBusinessType(Integer businessType) {
        for (BusinessFieldEnum businessFieldEnum : values()) {
            if (Objects.equals(businessFieldEnum.getBusinessType(), businessType)) {
                return businessFieldEnum.getFieldList();
            }
        }
        return new ArrayList<>();
    }
}
